<script>
$(document).ready(function(){
	{params}
	
	var c = {
		initv:function(){
			this.cnum 		= params.cnum;
			this.ismobile 	= params.ismobile;
			this.hmode 		= params.hmode;
			if(this.hmode==undefined)this.hmode = '1';
			js.ajax.get({
				url:'api/home/index'
			},function(ret){
				c.showdata(ret.data);
			});
		},
		closes:function(){
			if(this.hmode=='1'){
				reim.closetabsnow();
			}else{
				home.closetabs('tcompany');
			}
		},
		showdata:function(da){
			this.companyJoin(da.companyJoin);
			js.initbtn(this);
		},
		companyJoin:function(da){
			this.joinData = da;
			var i=0,len = da.length,d,str='';
			for(i=0;i<len;i++){
				d = da[i];
				if(!d.logo)d.logo='images/nologo.png';
				str+='<div class="rock-list-item rock-hover">';
				str+='<img src="'+d.logo+'" class="radius5" height="24" width="24" align="absmiddle"> ';
				str+=''+d.name+'';
				if(d.state=='1'){
					if(this.cnum==d.num){
						str+='<font color=green>✔当前</font>';
					}else{
						str+='<font><button clickevt="openjoin,'+i+'" class="webbtn webbtn-mini webbtn-default">切换</button></font>';
					}
				}else{
					str+=' <span class="rock-badge bg-danger">待激活</span>';
					str+=' <button class="webbtn webbtn-mini bg-danger">激活</button>';
				}
				
				str+='</div>';
			}
			$('#comjoin{rand}').html(str);
		},
		openjoin:function(oi,i){
			var d = this.joinData[i];
			js.ajax.get({
				url:'api/home/change',
				loading:'切换中...',
				data:{
					cid:d.id
				}
			}, function(ret){
				c.changeok(d);
				
			});
			
		},
		changeok:function(d){
			if(this.ismobile==0){
				d.hmode=this.hmode;
				xcy.opencompany(d);
			}else{
				var cans = {url:'we/index',name:d.name,params:{cnum:d.num,title:d.name}};
				js.setoption('defnowurl', cans);
				this.closes();
				js.loading('切换中...')
				setTimeout('js.reload()',200);
			}
		}
	}
	c.initv();
});
</script>
<div align="center">
	
	
	<div style="max-width:300px;margin-top:70px;" align="left">
		<div style="padding:15px 5px 2px 10px;" class="hui fontsize12">我加入的单位</div>
		<div class="rock-panel rock-border rock-radius rock-list-group" id="comjoin{rand}">
			<div class="rock-list-item rock-hover">
				单位
			</div>
			
			
			
		</div>
	
	</div>
	
	


	<div style="margin-top:30px"><input clickevt="closes" style="width:150px" type="button" value="关闭" class="webbtn bg-outline-danger rock-border rock-hover"></div>	
	
</div>